/* 
封装请求函数
*/
import axios from 'axios'
import {message} from 'antd'

export default (url,data,method = "GET")=>{
    return new Promise((resove,reject)=>{
        let promise
        if(method === "POST"){
            promise = axios({
                 url,
                 data,
                 method:"POST"
             })
         }else{
     
            promise = axios({
                 url,
                 params:data
             })
         }
        //统一进行错误的处理
         promise.then((response)=>{
             resove(response)
         }).catch((error)=>{
            message.error('出错了'+error.message)
         })

    })
   
}